package com.weblog.weblog.admin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @author gc
 * @date 2023年11月09日 16:38
 */

@Configuration
@EnableAsync
public class TheadPoolConfig {

    @Bean
    public ThreadPoolTaskExecutor threadPoolTaskExecutor(){
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10);       //核心线程
        executor.setMaxPoolSize(20);        //最大线程
        executor.setQueueCapacity(100);    //队列容量
        executor.setThreadNamePrefix("weblogThreadPool-");   //线程前缀
        executor.initialize();
        return executor;
    }

}
